package com.zhj.common.config;

import com.zhj.common.advice.GlobalExceptionAdvice;
import com.zhj.common.advice.GlobalResultAdvice;
import com.zhj.common.constant.ConfigKey;

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 全局自动装配
 * 创建人: zhonghaijun
 * 创建时间: 2023-07-27 15:20:27
 */
@Configuration
@ConditionalOnProperty(prefix = ConfigKey.SYSTEM_CONFIG_PREFIX, name = "global.result", havingValue = "true", matchIfMissing = true)
public class GlobalAutoConfiguration {

    /**
     * 全局异常封装
     *
     * @return {@code GlobalExceptionAdvice }
     * @author zhonghaijun
     * @date 2023-07-27 15:20:27
     */
    @Bean
    public GlobalExceptionAdvice globalExceptionAdvice() {
        return new GlobalExceptionAdvice();
    }

    /**
     * 全局结果封装
     *
     * @return {@code GlobalResultAdvice }
     * @author zhonghaijun
     * @date 2023-07-27 15:20:28
     */
    @Bean
    public GlobalResultAdvice globalResultAdvice() {
        return new GlobalResultAdvice();
    }

}
